<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" label-width="68px">
   <!--   <el-form-item label="应付金额" prop="ordersTotalMoney">
        <el-input
          v-model="queryParams.ordersTotalMoney"
          placeholder="请输入应付金额"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
    <!--  <el-form-item label="实付金额" prop="ordersMoney">
        <el-input
          v-model="queryParams.ordersMoney"
          placeholder="请输入实付金额"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="数量" prop="ordersCounts">
        <el-input
          v-model="queryParams.ordersCounts"
          placeholder="请输入数量"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
	  <el-form-item label="订单号" prop="ordersCode">
	    <el-input
	      v-model="queryParams.ordersCode"
	      placeholder="请输入订单号"
	      clearable
	      size="small"
	      @keyup.enter.native="handleQuery"
	    />
	  </el-form-item>
	   <el-form-item label="订单状态" prop="ordersStatus">
	      <el-select v-model="queryParams.ordersStatus" placeholder="请选择订单状态" clearable size="small">
	        <el-option :value="0" label="待付款"></el-option>
	        <el-option :value="1" label="待发货"></el-option>
	        <el-option :value="2" label="已发货"></el-option>
	        <el-option :value="3" label="已完成"></el-option>
	        <el-option :value="4" label="待评价"></el-option>
	        <el-option :value="5" label="已取消"></el-option>
			<el-option :value="6" label="已付款"></el-option>
			<el-option :value="7" label="已收货"></el-option>
	      </el-select>
	    </el-form-item>
		<el-form-item label="支付方式" prop="ordersPayment">
		   <el-select v-model="queryParams.ordersPayment" placeholder="请选择支付方式" clearable size="small">
		     <el-option :value="1" label="支付宝"></el-option>
		     <el-option :value="2" label="微信"></el-option>
		     <el-option :value="3" label="银联"></el-option>
		   </el-select>
		 </el-form-item>
		 <el-form-item label="物流公司" prop="ordersExpressId">
		    <el-select v-model="queryParams.ordersExpressId" placeholder="请选择订单状态" clearable size="small">
		     <el-option :value="1" label="申通快递"></el-option>
		     <el-option :value="2" label="圆通快递"></el-option>
		     <el-option :value="3" label="韵达快递"></el-option>
		     <el-option :value="4" label="中通快递"></el-option>
		     <el-option :value="5" label="顺丰快递"></el-option>
		     <el-option :value="6" label="宅急送快运"></el-option>
		     <el-option :value="7" label="汇通快递"></el-option>
		     <el-option :value="8" label="鑫飞鸿速递"></el-option>
		     <el-option :value="9" label="能达快递"></el-option>
		     <el-option :value="10" label="星晨急便"></el-option>
		    </el-select>
		  </el-form-item>
     <el-form-item label="下单时间" prop="ordersTime">
        <el-date-picker clearable size="small" style="width: 200px"
          v-model="queryParams.ordersTime"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="选择订单时间">
        </el-date-picker>
      </el-form-item>
     <!-- <el-form-item label="购买用户标识—外键" prop="ordersUserId">
        <el-input
          v-model="queryParams.ordersUserId"
          placeholder="请输入购买用户标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
    <!--  <el-form-item label="商品标识—外键" prop="ordersGoodsId">
        <el-input
          v-model="queryParams.ordersGoodsId"
          placeholder="请输入商品标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="店铺标识—外键" prop="ordersStoreId">
        <el-input
          v-model="queryParams.ordersStoreId"
          placeholder="请输入店铺标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
     <!-- <el-form-item label="规格标识—外键" prop="ordersGoodsSpecificationId">
        <el-input
          v-model="queryParams.ordersGoodsSpecificationId"
          placeholder="请输入规格标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
     <!-- <el-form-item label="地址标识—外键" prop="ordersPathId">
        <el-input
          v-model="queryParams.ordersPathId"
          placeholder="请输入地址标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
     <!-- <el-form-item label="是否为退款订单 0否 1是" prop="ordersForRefund">
        <el-input
          v-model="queryParams.ordersForRefund"
          placeholder="请输入是否为退款订单 0否 1是"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <!-- <el-form-item label="优惠券标识—外键" prop="ordersDiscountCouponId">
        <el-input
          v-model="queryParams.ordersDiscountCouponId"
          placeholder="请输入优惠券标识—外键"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
    <!--  <el-form-item label="订单类型 0店铺订单 1商品订单 2会员订单" prop="ordersDiscountTypes">
        <el-input
          v-model="queryParams.ordersDiscountTypes"
          placeholder="请输入订单类型 0店铺订单 1商品订单 2会员订单"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
    <!--  <el-form-item label="备注" prop="ordersContent">
        <el-input
          v-model="queryParams.ordersContent"
          placeholder="请输入备注"
          clearable
          size="small"
          @keyup.enter.native="handleQuery"
        />
      </el-form-item> -->
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
     <!-- <el-col :span="1.5">
        <el-button
          type="primary"
          icon="el-icon-check"
          size="mini"
		  :disabled="single"
          @click="handleAdd"
          v-hasPermi="['system:orders:add']"
        >发货</el-button>
      </el-col> -->
      <el-col :span="1.5">
        <el-button
          type="success"
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['system:orders:edit']"
        >修改</el-button>
      </el-col>
     <!-- <el-col :span="1.5">
        <el-button
          type="danger"
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['system:orders:remove']"
        >删除</el-button>
      </el-col> -->
		<el-col :span="1.5">
        <el-button
          type="warning"
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['system:orders:export']"
        >导出</el-button>
      </el-col>
    </el-row>

    <el-table v-loading="loading" :data="ordersList" @selection-change="handleSelectionChange">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="下单时间" align="center" prop="ordersTime" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.ordersTime, '{y}年{m}月{d} {h}时{m}分') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="订单号" align="center" prop="ordersCode" width="100">
		  <template slot-scope="scope">
		  {{scope.row.ordersCode}}
		  </template>
	  </el-table-column>
	  <el-table-column label="物流名称" align="center" prop="ordersExpressId" width="100">
	  		  <template slot-scope="scope">
	  		  {{scope.row.expres.expressName}}
	  		  </template>
	  </el-table-column>
      <el-table-column label="订单状态" align="center" prop="ordersStatus">
		  <template slot-scope="scope">
		  	{{scope.row.ordersStatus == 0 ? '待付款':(scope.row.ordersStatus == 1 ? '待发货' : (scope.row.ordersStatus==2 ? '已发货':(scope.row.ordersStatus==3 ? '已完成':(scope.row.ordersStatus==4 ? '待评价':(scope.row.ordersStatus==5 ? '已取消':'null')))))}}
		  </template>
	  </el-table-column>
      <el-table-column label="用户姓名" align="center" prop="ordersUserId">
		  <template slot-scope="scope">
		  	{{scope.row.personage.isTechnician !=null ? (scope.row.personage.isTechnician == 0 ? scope.row.personage.username:'是技师'):'暂无'}}
		  </template>
	  </el-table-column>
      <el-table-column label="商品名称" align="center" prop="ordersGoodsId" width="100">
		  <template slot-scope="scope">
		  	{{scope.row.goods.goodsName}}
		  </template>
	  </el-table-column>
	  <el-table-column label="商品图片" align="center" prop="goodsThumbnailImg" width="110">
	     <template style="width: 100px; height: 100px;border-radius: 50%;"
	  	   slot-scope="scope" v-if="scope.row.goods.goodsThumbnailImg != null && scope.row.goods.goodsThumbnailImg != ''">
	  		<el-popover trigger="hover" placement="top">
	  			<img v-for="(item, index) in scope.row.goods.goodsThumbnailImg.split(',')" style="width: 100px;margin-left: 5px;" :key="index" :src="item" />
	  			<div slot="reference" class="name-wrapper"><el-tag size="medium">查看</el-tag></div>
	  		</el-popover>
	  	  </template>
	  </el-table-column>
	  <el-table-column label="商品运费(元)" align="center" prop="ordersStoreId" width="110">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.storeManagement.storeManagementFreight +'元'}}
	  		  </template>
	  </el-table-column>
      <el-table-column label="规格名称" align="center" prop="ordersGoodsSpecificationId">
		  <template slot-scope="scope">
		  	{{scope.row.goodsSpecification.goodsSpecificationName}}
		  </template>
	  </el-table-column>
	  <el-table-column label="数量(个)" align="center" prop="ordersCounts">
	  		  <template slot-scope="scope">
	  		  			  {{scope.row.ordersCounts + '个'}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="实际付款(元)" align="center" prop="ordersMoney" width="120">
	  		  <template slot-scope="scope">
	  		  			  {{scope.row.ordersMoney + '元'}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="应付金额(元)" align="center" prop="ordersTotalMoney" width="120">
	  		  <template slot-scope="scope">
	  		  			  {{scope.row.ordersTotalMoney + '元'}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="支付类型" align="center" prop="ordersPayment">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.ordersPayment == 1 ? '支付宝':(scope.row.ordersPayment == 2 ?'微信':(scope.row.ordersPayment == 3 ? '银联':'null'))}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="送货方式" align="center" prop="ordersDeliverGoodss">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.ordersDeliverGoodss == 1 ? '快递发送':(scope.row.ordersDeliverGoodss == 2 ?'自送家门':'null')}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="收货姓名" align="center" prop="ordersPathId">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.shippingAddress.shippingAddressName}}
	  		  </template>
	  </el-table-column>
	  <el-table-column label="姓名电话" align="center" prop="ordersPathId" width="100">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.shippingAddress.shippingAddressPhone}}
	  		  </template>
	  </el-table-column>
      <el-table-column label="收货地址" align="center" prop="ordersPathId" width="170">
		  <template slot-scope="scope">
		  	{{scope.row.shippingAddress.shippingAddressProvince}}
			{{scope.row.shippingAddress.shippingAddressCity}}
			{{scope.row.shippingAddress.shippingAddressDistrict}}
			{{scope.row.shippingAddress.shippingAddressDetails}}
		  </template>
	  </el-table-column>
	  <el-table-column label="修改地址" align="center" class-name="small-padding fixed-width" width="130">
	    <template slot-scope="scope">
	      <el-button
	        size="mini"
	        type="text"
	        icon="el-icon-edit"
	        @click="handleUpdateee(scope.row)"
	        v-hasPermi="['system:orders:edit']"
	      >修改</el-button>
	    </template>
	  </el-table-column>
	  <el-table-column label="店铺名称" align="center" prop="ordersStoreId" width="110">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.storeManagement.storeManagementName}}
	  		  </template>
	  </el-table-column>
      <el-table-column label="退款订单" align="center" prop="ordersForRefund">
		  <template slot-scope="scope">
		  	{{scope.row.ordersForRefund == 0 ? '否':'是'}}
		  </template>
	  </el-table-column>
	  <el-table-column label="退款状态" align="center" prop="ordersRefund" width="100">
	  		  <template slot-scope="scope">
	  		  	{{scope.row.ordersRefund == 1 ? '审核中...':(scope.row.ordersRefund == 2 ? '退款中':(scope.row.ordersRefund == 3 ? '已退款':(scope.row.ordersRefund == 4 ? '未退款':'未申请退款')))}}
	  		  </template>
	  </el-table-column>
      <el-table-column label="优惠券" align="center" prop="ordersDiscountCouponId" width="110">
		  <template slot-scope="scope">
		  	{{scope.row.discountCoupon.discountCouponName}}
		  </template>
	  </el-table-column>
      <el-table-column label="订单类型" align="center" prop="ordersDiscountTypes">
		  <template slot-scope="scope">
		  	{{scope.row.ordersDiscountTypes == 0 ? '店铺订单':(scope.row.ordersDiscountTypes == 1 ?'商品订单':(scope.row.ordersDiscountTypes == 2 ? '会员订单':'null'))}}
		  </template>
	  </el-table-column>
      <el-table-column label="备注" align="center" prop="ordersContent" width="100"/>
	  <!-- <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="105">
	    <template slot-scope="scope">
			<el-button 
			type="primary" 
			round
			icon="el-icon-check"
			@click="handleUpdatee(scope.row)" 
			v-hasPermi="['system:orders:add']">
			 发货
			</el-button>
	    </template>
	  </el-table-column> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="130">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-edit"
            @click="handleUpdate(scope.row)"
            v-hasPermi="['system:orders:edit']"
          >修改</el-button>
		  
         <el-dropdown trigger="click" size="mini">
			   <el-button
			     size="mini"
			     type="text"
			     class="el-dropdown-link">
			   更多操作<i class="el-icon-arrow-down el-icon--right"></i></el-button>
               <el-dropdown-menu slot="dropdown">
                 <el-dropdown-item>
				 <el-button
				   size="mini"
				   type="text"
				   icon="el-icon-circle-check"
				   @click="handleUpdatee(scope.row)"
				   v-hasPermi="['system:orders:add']"
				 >去发货</el-button>
				 </el-dropdown-item>
				 <el-dropdown-item>
				 <el-button
				   size="mini"
				   type="text"
				   icon="el-icon-s-open"
				   @click="handleUpdateeee(scope.row)"
				   v-hasPermi="['system:orders:add']"
				 >打印小票</el-button>
				 </el-dropdown-item>
				 <el-dropdown-item>
				 <el-button
				   size="mini"
				   type="text"
				   icon="el-icon-delete"
				   @click="handleDelete(scope.row)"
				   v-hasPermi="['system:orders:add']"
				 >移收回收站</el-button>
				 </el-dropdown-item>
				 <el-dropdown-item>
				 <el-button
				   size="mini"
				   type="text"
				   icon="el-icon-s-platform"
				   @click="handleUpdateeeee(scope.row)"
				   v-hasPermi="['system:orders:add']"
				 >订单详情</el-button>
				 </el-dropdown-item>
               </el-dropdown-menu>
             </el-dropdown>

		 
        </template>
      </el-table-column>
    </el-table>
    
    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
	
	<!-- 添加或修改订单对话框 -->
	<el-dialog :title="title" :visible.sync="opensssss" width="600px" append-to-body>
	  <el-form ref="form" :model="form"  :rules="rules" label-width="90px">
		<el-form ref="form" :model="form" label-width="70px">
		  <el-form-item label="订单号码" prop="ordersCode" >
		    <el-input v-model="form.ordersCode"></el-input>
		  </el-form-item>
		  <el-form-item label="用户姓名" align="center" prop="ordersUserId">
		    <el-input v-for="(item,index) in personage" v-if="item.uid == form.ordersUserId" v-model="item.username"></el-input>
		  </el-form-item>
		  <el-form-item label="支付方式" align="center"  prop="ordersPayment">
		  <el-input v-for="(item,index) in payment" v-if="item.paymentId == form.ordersPayment" v-model="item.paymentType"></el-input>
		  </el-form-item>
		  <el-form-item label="收货姓名" align="center"  prop="ordersPathId">
		     <el-input v-for="(item,index) in address" v-if="item.shippingAddressId == form.ordersPathId" v-model="item.shippingAddressName"></el-input>
		  </el-form-item>
		  <el-form-item label="收货电话" align="center"  prop="ordersPathId">
		     <el-input v-for="(item,index) in address" v-if="item.shippingAddressId == form.ordersPathId" v-model="item.shippingAddressPhone"></el-input>
		  </el-form-item>
		  <el-form-item label="收货地址" align="center"  prop="ordersPathId">
		     <el-input v-for="(item,index) in address" v-if="item.shippingAddressId == form.ordersPathId" v-model="item.shippingAddressProvince+item.shippingAddressCity+item.shippingAddressDistrict+item.shippingAddressDetails"></el-input>
		  </el-form-item>
		  <el-form-item label="商品名称" prop="ordersGoodsId">
		     <el-input v-for="(item,index) in goods" v-if="item.goodsId == form.ordersGoodsId" v-model="item.goodsName"></el-input>
		  </el-form-item>
		  <el-form-item label="规格" prop="ordersGoodsSpecificationId">
		    <el-input v-for="(item,index) in specification" v-if="item.goodsSpecificationId == form.ordersGoodsSpecificationId" v-model="item.goodsSpecificationName"></el-input>
		  </el-form-item>
		  <el-form-item label="总金额" style="width: 100%;" prop="ordersTotalMoney">
		    <el-input v-model="form.ordersTotalMoney">
					<template slot="append">元</template>
				</el-input>
		  </el-form-item>
		  <el-form-item label="运费费用" prop="ordersStoreId">
		   <el-input v-for="(item,index) in storeManagement" v-if="item.storeManagementId == form.ordersStoreId" v-model="item.storeManagementFreight">
			   <template slot="append">元</template>
		   </el-input>
		  </el-form-item>
		  <el-form-item label="数量" prop="ordersCounts">
			  <el-input v-model="form.ordersCounts">
				  <template slot="append">个</template>
			  </el-input>
		  </el-form-item>
		  <el-form-item label="小计" prop="ordersGoodsId">
		   <el-input v-for="(item,index) in goods" v-if="item.goodsId == form.ordersGoodsId" v-model="item.goodsMoney">
			   <template slot="append">元</template>
		   </el-input>
		  </el-form-item>
		</el-form>
	  </el-form>
	  <div slot="footer" class="dialog-footer">
	    <!-- <el-button type="primary" @click="submitFormmmmm">确 定</el-button> -->
	    <el-button @click="cancelllll">取 消</el-button>
	  </div>
	</el-dialog>
	
	<!-- 添加或修改订单对话框 -->
	<el-dialog :title="title" :visible.sync="openssss" width="500px" append-to-body>
	  <el-form ref="form" :model="form" :rules="rules" label-width="80px">
		
	  </el-form>
	  <div slot="footer" class="dialog-footer">
	    <el-button type="primary" @click="submitFormmmm">确 定</el-button>
	    <el-button @click="cancellll">取 消</el-button>
	  </div>
	</el-dialog>
	
	<!-- 添加或修改订单对话框 -->
	<el-dialog :title="title" :visible.sync="opensss" width="600px" append-to-body>
	  <el-form ref="forms" :model="forms" :rules="rules" label-width="80px">
		  <el-form-item label="省"  prop="shippingAddressProvince">
		    <el-select placeholder="请选择省" @change="selectCity" v-model="forms.shippingAddressProvince">
				<el-option v-for="(item,index) in habitationsheng"  :label="item.name" :value="item.name" ></el-option>
		    </el-select>
		  </el-form-item>
		  <el-form-item label="市" prop="shippingAddressCity">
		    <el-select  placeholder="请选择市" @change="selectCityy" v-model="forms.shippingAddressCity">
		  	<el-option v-for="(item,index) in habitationshi":label="item.name" :value="item.name" ></el-option>
		    </el-select>
		  </el-form-item>
		  <el-form-item label="区" prop="shippingAddressDistrict">
		    <el-select placeholder="请选择区" v-model="forms.shippingAddressDistrict">
				<el-option v-for="(item,index) in habitationqu" :label="item.name" :value="item.name"></el-option>
		    </el-select>
		  </el-form-item>
		<el-form-item label="详细地址" prop="shippingAddressDetails">
		   <el-input v-model="forms.shippingAddressDetails"></el-input>
		</el-form-item>
	  </el-form>
	  <div slot="footer" class="dialog-footer">
	    <el-button type="primary" @click="submitFormmm">确 定</el-button>
	    <el-button @click="cancelll">取 消</el-button>
	  </div>
	</el-dialog>
	
	<!-- 添加或修改订单对话框 -->
	<el-dialog :title="title" :visible.sync="openss" width="500px" append-to-body>
	  <el-form ref="form" :model="form" :rules="rules" label-width="80px">
		  <el-form-item label="订单号" prop="ordersCode">
		     <el-input v-model="form.ordersCode" placeholder="请输入订单号" />
		   </el-form-item> 
	    <el-form-item label="物流公司" prop="ordersExpressId">
	      <el-select v-model="form.ordersExpressId" placeholder="请选择物流公司">
			  <el-option :value="1" label="申通快递"></el-option>
			  <el-option :value="2" label="圆通快递"></el-option>
			  <el-option :value="3" label="韵达快递"></el-option>
			  <el-option :value="4" label="中通快递"></el-option>
			  <el-option :value="5" label="顺丰快递"></el-option>
			  <el-option :value="6" label="宅急送快运"></el-option>
			  <el-option :value="7" label="汇通快递"></el-option>
			  <el-option :value="8" label="鑫飞鸿速递"></el-option>
			  <el-option :value="9" label="能达快递"></el-option>
			  <el-option :value="10" label="星晨急便"></el-option>
	      </el-select>
	    </el-form-item>
	  </el-form>
	  <div slot="footer" class="dialog-footer">
	    <el-button type="primary" @click="submitFormm">确 定</el-button>
	    <el-button @click="cancell">取 消</el-button>
	  </div>
	</el-dialog>
	
	
    <!-- 添加或修改订单对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
       <!-- <el-form-item label="应付金额" prop="ordersTotalMoney">
          <el-input v-model="form.ordersTotalMoney" placeholder="请输入应付金额" />
        </el-form-item> -->
        <!-- <el-form-item label="实付金额" prop="ordersMoney">
          <el-input v-model="form.ordersMoney" placeholder="请输入实付金额" />
        </el-form-item> -->
        <!-- <el-form-item label="数量" prop="ordersCounts">
          <el-input v-model="form.ordersCounts" placeholder="请输入数量" />
        </el-form-item> -->
       <!-- <el-form-item label="订单时间" prop="ordersTime">
          <el-date-picker clearable size="small" style="width: 200px"
            v-model="form.ordersTime"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="选择订单时间">
          </el-date-picker>
        </el-form-item> -->
       <!-- <el-form-item label="订单号" prop="ordersCode">
          <el-input v-model="form.ordersCode" placeholder="请输入订单号" />
        </el-form-item> -->
        <el-form-item label="订单状态"><!-- v-if="form.ordersForRefund == 0" -->
          <el-select v-model="form.ordersStatus" placeholder="请选择订单状态">
            <el-option :value="0" label="待付款"></el-option>
			<el-option :value="1" label="待发货"></el-option>
			<el-option :value="2" label="已发货"></el-option>
			<el-option :value="3" label="已完成"></el-option>
			<el-option :value="4" label="待评价"></el-option>
			<el-option :value="5" label="已取消"></el-option>
			<el-option :value="6" label="已付款"></el-option>
			<el-option :value="7" label="已收货"></el-option>
          </el-select>
        </el-form-item>
		<el-form-item label="退款状态" ><!-- v-if="form.ordersForRefund == 1" -->
		  <el-select v-model="form.ordersRefund" placeholder="请选择订单状态">
			<el-option :value="0" label="未申请退款"></el-option>
			<el-option :value="1" label="审核中"></el-option>
			<el-option :value="2" label="退款中"></el-option>
			<el-option :value="3" label="已退款"></el-option>
			<el-option :value="4" label="未退款"></el-option>
		  </el-select>
		</el-form-item>
        <!-- <el-form-item label="用户姓名" prop="ordersUserId">
          <el-select v-model="form.ordersUserId" placeholder="请选择用户" style="width: 100%">
			  <el-option v-for="(item,index) in personage" :key="index" :value="item.uid" :label="item.username"></el-option>
		  </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="商品名称" prop="ordersGoodsId">
          <el-select v-model="form.ordersGoodsId" placeholder="请选择商品名称" style="width: 100%">
			  <el-option v-for="(item,index) in goods" :key="index" :value="item.goodsId" :label="item.goodsName"></el-option>
          </el-select>
        </el-form-item> -->
       <!-- <el-form-item label="店铺名称" prop="ordersStoreId">
          <el-select v-model="form.ordersStoreId" placeholder="请选择店铺名称" style="width: 100%">
          	  <el-option v-for="(item,index) in storeManagement" :key="index" :value="item.storeManagementId" :label="item.storeManagementName"></el-option>
          </el-select>
        </el-form-item> -->
       <!-- <el-form-item label="规格名称" prop="ordersGoodsSpecificationId">
         <el-select v-model="form.ordersGoodsSpecificationId" placeholder="请选择规格名称" style="width: 100%">
         	  <el-option v-for="(item,index) in specification" :key="index" :value="item.goodsSpecificationId" :label="item.goodsSpecificationName"></el-option>
         </el-select>
        </el-form-item> -->
       <!-- <el-form-item label="地址省份" prop="ordersPathId" style="width: 200px">
          <el-select v-model="form.ordersPathId" placeholder="请选择省份">
          	  <el-option v-for="(item,index) in address" :key="index" :value="item.shippingAddressId" :label="item.shippingAddressProvince"></el-option>
          </el-select>
        </el-form-item>
		<el-form-item label="市" prop="ordersPathId" style="width: 200px">
		  <el-select v-model="form.ordersPathId" placeholder="请选择市">
		  	  <el-option v-for="(item,index) in address" :key="index" :value="item.shippingAddressId" :label="item.shippingAddressCity"></el-option>
		  </el-select>
		</el-form-item>
		<el-form-item label="区/镇/街道" prop="ordersPathId" style="width: 250px">
		  <el-select v-model="form.ordersPathId" placeholder="请选择区/镇/街道">
		  	  <el-option v-for="(item,index) in address" :key="index" :value="item.shippingAddressId" :label="item.shippingAddressDistrict"></el-option>
		  </el-select>
		</el-form-item>
		<el-form-item label="详细地址" prop="ordersPathId">
		  <el-input v-model="form.ordersPathId" type="textarea" placeholder="请输入内容">
			
		  </el-input>
		</el-form-item> -->
       <!-- <el-form-item label="是否退款" prop="ordersForRefund">
		  <el-select v-model="form.ordersForRefund" placeholder="是否退款">
		  	  <el-option v-for="(item,index) in orders" :key="index" :value="item.ordersId" :label="item.ordersForRefund"></el-option>
		  </el-select>
        </el-form-item> -->
        <!-- <el-form-item label="优惠券" prop="ordersDiscountCouponId">
          <el-input v-model="form.ordersDiscountCouponId" placeholder="请输入优惠券" />
        </el-form-item> -->
       <!-- <el-form-item label="订单类型" prop="ordersDiscountTypes">
          <el-input v-model="form.ordersDiscountTypes" placeholder="请输入订单类型" />
        </el-form-item> -->
        <!-- <el-form-item label="备注" prop="ordersContent">
          <el-input v-model="form.ordersContent" placeholder="请输入备注" />
        </el-form-item> -->
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { listOrders, getOrders, delOrders, addOrders, updateOrders, exportOrders } from "@/api/system/orders";
import {listPersonage} from "@/api/system/personage";
import {listPayment} from "@/api/system/payment";
import {listGoods} from "@/api/system/goods";
import {listManagement} from "@/api/system/storeManagement";
import {listSpecification} from "@/api/system/specification";
import {listAddress,updateAddress} from "@/api/system/address";
import {listHabitation} from "@/api/system/habitation";
export default {
  name: "Orders",
  data() {
    return {
		 form: {
		  name: '',
		  region: '',
		  date1: '',
		  date2: '',
		  delivery: false,
		  type: [],
		  resource: '',
		  desc: ''
		},
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 总条数
      total: 0,
      // 订单表格数据
      ordersList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
	  openss:false,
	  opensss:false,
	  openssss:false,
	  opensssss:false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        ordersTotalMoney: undefined,
        ordersMoney: undefined,
        ordersCounts: undefined,
        ordersTime: undefined,
        ordersCode: undefined,
        ordersStatus: undefined,
        ordersUserId: undefined,
        ordersGoodsId: undefined,
        ordersStoreId: undefined,
        ordersGoodsSpecificationId: undefined,
        ordersPathId: undefined,
		ordersPayment:undefined,
        ordersForRefund: undefined,
        ordersDiscountCouponId: undefined,
        ordersDiscountTypes: undefined,
        ordersContent: undefined
      },
	  personage:[],
	  payment:[],
	  goods:[],
	  storeManagement:[],
	  specification:[],
	  address:[],
	  orders:[],
	  habitationsheng:[],
	  habitationshi:[],
	  habitationqu:[],
      // 表单参数
      form: {},
	  forms:{},
      // 表单校验
      rules: {
      }
    };
  },
  created() {
    this.getList();
	this.getPersonageList();
	this.getGoodsList();
	this.getStoreManagementList();
	this.getSpecificationList();
	this.getAddressList(); 
	this.getPaymentList();
	this.getHabitationList();
  },
  methods: {
	  onSubmit() {
		  console.log('submit!');
		},
    /** 查询订单列表 */
    getList() {
      this.loading = true;
      listOrders(this.queryParams).then(response => {
        this.ordersList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
	/* 查询省*/
	getHabitationList() {
	 var querys = {
		 pid : 0
	 }
	 console.log(querys);
	 listHabitation(querys).then(response =>{
		 this.habitationsheng=response.rows;
		 console.log(response);
	 })
	}, 
	// 点击省触发事件
	selectCity(name){
		var querys = {name : name}
	 listHabitation(querys).then(response =>{
		 var sheng = response.rows;
		 querys = {pid : sheng[0].id}
		 listHabitation(querys).then(response =>{
		 		 this.habitationshi = response.rows;
		 		 console.log(this.habitationshi);
		 })
	 })
	},
	
	//点击市触发事件
	selectCityy(name){
		var querys = {name : name}
	 listHabitation(querys).then(response =>{
		 var shi = response.rows;
		 querys = {pid : shi[0].id}
		 listHabitation(querys).then(response =>{
		 		 this.habitationqu = response.rows;
		 		 console.log(this.habitationqu);
		 })
	 })
	},
	/* 查询退款订单 */
	getPersonageList() {
	 listOrders().then(response =>{
		 this.orders=response.rows;
	 })
	},
	/* 查询用户列表 */
	getPersonageList() {
	 listPersonage().then(response =>{
		 this.personage=response.rows;
	 })
	},
	/* 查询支付列表 */
	getPaymentList() {
	 listPayment().then(response =>{
		 this.payment=response.rows;
	 })
	},
	/* 查询商品列表 */
	getGoodsList() {
	 listGoods().then(response =>{
		 this.goods=response.rows;
	 })
	},
	/* 查询店铺列表 */
	getStoreManagementList() {
	 listManagement().then(response =>{
		 console.log(response.rows);
		 this.storeManagement=response.rows;
	 })
	},
	/* 查询商品规格表*/
	getSpecificationList() {
	 listSpecification().then(response =>{
		 this.specification=response.rows;
		 console.log(response.rows);
	 })
	},
	/* 查询地址列表*/
	getAddressList() {
	 listAddress().then(response =>{
		 this.address=response.rows;
		 console.log(response.rows);
	 })
	},
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
	// 取消按钮
	cancell() {
	  this.openss = false;
	  this.reset();
	},
	// 取消按钮
	cancelll() {
	  this.opensss= false;
	  this.reset();
	},
	// 取消按钮
	cancellll() {
	  this.openssss= false;
	  this.reset();
	},
	// 取消按钮
	cancelllll() {
	  this.opensssss= false;
	  this.reset();
	},
    // 表单重置
    reset() {
      this.form = {
        ordersId: undefined,
        ordersTotalMoney: undefined,
        ordersMoney: undefined,
        ordersCounts: undefined,
        ordersTime: undefined,
        ordersCode: undefined,
        ordersStatus: "0",
        ordersUserId: undefined,
        ordersGoodsId: undefined,
        ordersStoreId: undefined,
        ordersGoodsSpecificationId: undefined,
        ordersPathId: undefined,
        ordersForRefund: undefined,
		ordersPayment:undefined,
        ordersDiscountCouponId: undefined,
        ordersDiscountTypes: undefined,
        ordersContent: undefined
      };
	  this.forms = {
		shippingAddressId: undefined,
	    shippingAddressProvince: undefined,
	    shippingAddressCity: undefined,
	    shippingAddressDistrict: undefined,
	    shippingAddressDetails: undefined,
	  };
      this.resetForm("form");
	  this.resetForm("forms");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map(item => item.ordersId)
      this.single = selection.length!=1
      this.multiple = !selection.length
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const ordersId = row.ordersId || this.ids
      getOrders(ordersId).then(response => {
        this.form = response.data;
        this.open = true;
        this.title = "修改订单";
      });
    },
	
	
	/** 发货按钮操作 */
	handleUpdatee(row) {
		console.log(row);
	  this.reset();
	  const ordersId = row.ordersId || this.ids
	  getOrders(ordersId).then(response => {
	    this.form = response.data;
	    this.openss = true;
	    this.title = "发货订单";
	  });
	},
	
	/** 修改地址操作 */
	handleUpdateee(row) {
		console.log(row);
	  this.reset();
	  const ordersId = row.ordersId || this.ids
	  getOrders(ordersId).then(response => {
	    this.form = response.data;
	    this.opensss = true;
	    this.title = "修改地址";
	  });
	},
	/** 打印小票操作 */
	handleUpdateeee(row) {
		console.log(row);
	  this.reset();
	  const ordersId = row.ordersId || this.ids
	  getOrders(ordersId).then(response => {
	    this.form = response.data;
	    this.openssss = true;
	    this.title = "打印小票";
	  });
	},
	/** 订单详情操作 */
	handleUpdateeeee(row) {
		console.log(row);
	  this.reset();
	  const ordersId = row.ordersId || this.ids
	  getOrders(ordersId).then(response => {
	    this.form = response.data;
	    this.opensssss = true;
	    this.title = "订单详情";
	  });
	},
	
	
    /** 提交按钮 */
    submitForm: function() {
      this.$refs["form"].validate(valid => {
        if (valid) {
          if (this.form.ordersId != undefined) {
            updateOrders(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("修改成功");
                this.open = false;
                this.getList();
              }
            });
          } else {
            addOrders(this.form).then(response => {
              if (response.code === 200) {
                this.msgSuccess("新增成功");
                this.openss = false;
                this.getList();
              }
            });
          }
        }
      });
    },
	
	/** 提交按钮 */
	submitFormm: function() {
	  this.$refs["form"].validate(valid => {
	    if (valid) {
	      if (this.form.ordersId != undefined) {
			this.form.ordersStatus = 2;
	        updateOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("发货成功");
	            this.openss = false;
	            this.getList();
	          }
	        });
	      } else {
	        addOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("新增成功");
	            this.openss = false;
	            this.getList();
	          }
	        });
	      }
	    }
	  });
	},
	
	/** 提交按钮 */
	submitFormmm: function() {
	  this.$refs["forms"].validate(valid => {
	    if (valid) {
			this.forms.shippingAddressId = this.form.ordersPathId ;
	      if (this.forms.shippingAddressId != undefined) {
	        updateAddress(this.forms).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("修改成功");
	            this.opensss = false;
	            this.getList();
	          }
	        });
	      } else {
	        updateAddress(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("新增成功");
	            this.opensss = false;
	            this.getList();
	          }
	        });
	      }
	    }
	  });
	},
	/** 提交按钮 */
	submitFormmmm: function() {
	  this.$refs["form"].validate(valid => {
	    if (valid) {
	      if (this.form.ordersId != undefined) {
	        updateOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("修改成功");
	            this.openssss = false;
	            this.getList();
	          }
	        });
	      } else {
	        addOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("新增成功");
	            this.openssss = false;
	            this.getList();
	          }
	        });
	      }
	    }
	  });
	},
	
	/** 提交按钮 */
	submitFormmmmm: function() {
	  this.$refs["form"].validate(valid => {
	    if (valid) {
	      if (this.form.ordersId != undefined) {
	        updateOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("修改成功");
	            this.opensssss = false;
	            this.getList();
	          }
	        });
	      } else {
	        addOrders(this.form).then(response => {
	          if (response.code === 200) {
	            this.msgSuccess("新增成功");
	            this.opensssss= false;
	            this.getList();
	          }
	        });
	      }
	    }
	  });
	},
	
    /** 删除按钮操作 */
    handleDelete(row) {
      const ordersIds = row.ordersId || this.ids;
      this.$confirm('是否确认删除订单编号为"' + ordersIds + '"的数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return delOrders(ordersIds);
        }).then(() => {
          this.getList();
          this.msgSuccess("删除成功");
        }).catch(function() {});
    },
    /** 导出按钮操作 */
    handleExport() {
      const queryParams = this.queryParams;
      this.$confirm('是否确认导出所有订单数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(function() {
          return exportOrders(queryParams);
        }).then(response => {
          this.download(response.msg);
        }).catch(function() {});
    }
  }
};
</script>
<style>
  .el-dropdown-link {
    cursor: pointer;
    color: #409EFF;
  }
  .el-icon-arrow-down {
    font-size: 12px;
  }
</style>